<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('salesman');
    $id = empty($_POST['id']) ? '' :$_POST['id'];
    $state = empty($_POST['state']) ? '' :$_POST['state'];
    if(!empty($id) && !empty($state)){
        if($state == 1){
            $time = time();
            $dosql->ExecNoneQuery("UPDATE dyspw_shop_detailed SET case_state = 1, handle_time={$time} WHERE `id`={$id}");
            $result['states'] = 'y';
            $result['info'] = '审核通过即将刷新';
            exit(json_encode($result));
        }elseif ($state == 2) {
            $detailed = $dosql->GetOne("SELECT * FROM dyspw_shop_detailed WHERE `id`=$id");
            $member = $dosql->GetOne("SELECT * FROM dyspw_member WHERE `id`={$detailed['u_id']}");
            // print_r($member);exit;
            $time = time();
            $dosql->ExecNoneQuery("UPDATE dyspw_shop_detailed SET case_state = 2, handle_time={$time} WHERE `id`={$id}");
            $dosql->ExecNoneQuery("UPDATE dyspw_member SET balance = balance+{$detailed['cash_money']} WHERE `id`={$detailed['u_id']}");
            $result['states'] = 'y';
            $result['info'] = '驳回成功即将刷新';
            exit(json_encode($result));
        }
    }
 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员管理</title>
<link href="templates/style/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="templates/js/jquery.min.js"></script>
<script type="text/javascript" src="templates/js/forms.func.js"></script>
</head>
<body>
<div class="topToolbar"> <span class="title">会员管理</span> <a href="javascript:location.reload();" class="reload">刷新</a></div>
<form name="form" id="form" method="post" action="member_save.php">
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="dataTable">
		<tr align="left" class="head">
			<td width="2%" height="36" class="firstCol"><input type="checkbox" name="checkid" id="checkid" onclick="CheckAll(this.checked);"></td>
			<td width="3%">ID</td>
			<td width="10%">用户名</td>
			<td width="10%">真实姓名</td>
			<td width="10%">手机号</td>
			<td width="15%">开户行地址</td>
			<td width="15%">银行卡号</td>
			<td width="5%">银行</td>
			<td width="5%">金额</td>
			<td width="5%" class="endCol" style="text-align: center;">状态</td>
		</tr>
		<?php
		$dopage->GetPage("SELECT * FROM `#@__shop_detailed` where type = 2 ");
        // print_r($dosql->GetArray());exit;

		while($deta = $dosql->GetArray())
		{
            $bank = $dosql->GetOne("SELECT * FROM `#@__mem_bank` WHERE id={$deta['bank_id']}");
            $deta['bank_add'] = $bank['bank_add'];
            $deta['bank_num'] = $bank['bank_num'];
            $deta['bank_name'] = $bank['bank_name'];
            $deta['mobile'] = $bank['bank_mobile'];
            $deta['nickname'] = $bank['username'];

		?>
		<tr align="left" class="dataTr">
			<td height="60" class="firstCol"><input type="checkbox" name="checkid[]" id="checkid[]" value="<?php echo $deta['id']; ?>" /></td>
            <td><?php echo $deta['id']; ?></td>
            <td><?php echo $deta['u_name']; ?></td>
            <td><?php echo $deta['nickname']; ?></td>
            <td><?php echo $deta['mobile']; ?></td>
            <td><?php echo $deta['bank_add']; ?></td>
            <td><?php echo $deta['bank_num']; ?></td>
            <td><?php echo $deta['bank_name']; ?></td>
			<td><?php echo $deta['cash_money']; ?></td>

            <style media="screen">
                .state_btn{display: none;}
            </style>
            <script type="text/javascript">
                function onstate(obj){
                    obj.parent().find('.state_btn').css("display",'inline-block');
                }

                function state_ajax(id,state,money,u_id){
                    $.ajax({
                        url: '/xiaochengxu/admin/shop_detailed.php',
                        type: "post",
                        data: {'id':id,'state':state,'money':money,'u_id':u_id} ,
                        dataType: 'json',
                        success:function(res){
                            console.log(res.states);
                            alert(res.info);
                            window.location.reload();
                        }
                    })
                }
            </script>
			<td style="text-align: center;">
                <?php if($deta['case_state'] == 1){ ?>
                    <em style='font-style: normal;display: inline-block;width: 80px;line-height: 30px;background: #1b7e00c9;color: #fff;border-radius: 5px;font-size: 12px;'>已通过</em>
                <?php }else if($deta['case_state'] == 2){ ?>
                    <em style=' font-style:normal; display: inline-block;width: 80px;line-height: 30px;background: #d92424c9;color: #fff;border-radius: 5px;font-size: 12px;'>已驳回</em>
                <?php }else{ ?>
                    <a href="#" onclick="onstate($(this));" style="height:30px;width:80px;text-align:center;  font-style:normal; display: inline-block;line-height: 30px;background: #509ee1;color: #fff;border-radius: 5px;font-size: 12px;">审核中</a>
                    <a href="#" onclick="state_ajax(<?php echo $deta['id']; ?>,1);" class="state_btn" style="margin-right:0px;height:30px;width:80px;text-align:center;  font-style:normal; line-height: 30px;background: #1b7e00c9;color: #fff;border-radius: 5px;font-size: 12px;">通过</a>
                    <a href="#" onclick="state_ajax(<?php echo $deta['id']; ?>,2);" class="state_btn" style="margin-right:0px;height:30px;width:80px;text-align:center;  font-style:normal; line-height: 30px;background: #d92424c9;color: #fff;border-radius: 5px;font-size: 12px;">驳回</a>
                <?php } ?>
            </td>
		</tr>
		<?php
		}
		?>
	</table>
</form>
<?php

//判断无记录样式
if($dosql->GetTotalRow() == 0)
{
	echo '<div class="dataEmpty">暂时没有相关的记录</div>';
}
?>
<!-- <div class="bottomToolbar"><span class="selArea"><span>选择：</span> <a href="javascript:CheckAll(true);">全部</a> - <a href="javascript:CheckAll(false);">无</a> - <a href="javascript:DelAllNone('member_save.php');" onclick="return ConfDelAll(0);">删除</a></span> <a href="member_add.php" class="dataBtn">注册新会员</a> </div> -->
<div class="page"> <?php echo $dopage->GetList(); ?> </div>
<?php

//判断是否启用快捷工具栏
if($cfg_quicktool == 'Y')
{
?>
<!-- <div class="quickToolbar">
	<div class="qiuckWarp">
		<div class="quickArea"><span class="selArea"><span>选择：</span> <a href="javascript:CheckAll(true);">全部</a> - <a href="javascript:CheckAll(false);">无</a> - <a href="javascript:DelAllNone('member_save.php');" onclick="return ConfDelAll(0);">删除</a></span> <a href="member_add.php" class="dataBtn">注册新会员</a> <span class="pageSmall"> <?php echo $dopage->GetList(); ?> </span></div>
		<div class="quickAreaBg"></div>
	</div>
</div> -->
<?php
}
?>
</body>
</html>
